/*
	Input.h

	contains function declarations for internal input related functionality

	Author: Aidan Goddard 7/8/14
*/

#ifndef INPUT_H_INCLUDED
#define INPUT_H_INCLUDED

#include<Window.h>
#include<Xinput.h>
#include"SnowstormXEngineVars.h"

#define KEY_NEW_PRESS	0x80000000
#define KEY_NEW_RELEASE	0x40000000
#define XBOX_DEADZONE_DEFAULT 1.0f
#define XBOX_DEADZONE_DONT_CHANGE 2.0f

namespace Snowstorm
{
	class Input
	{
	public:
		static void KeyPressEvent(Snowstorm::Window *w, uint8_t key);
		static void KeyReleaseEvent(Snowstorm::Window *w, uint8_t key);
		static void MouseEvent(Snowstorm::Window *w, int delta_x, int delta_y, short delta_z);
		static void MouseMoveEvent(Snowstorm::Window *w, WPARAM wparam, LPARAM lparam);
		static void WindowCloseClicked(Snowstorm::Window *w, WPARAM wparam, LPARAM lparam);

		static void PollKeyboardInput(int base, int limit, uint32_t SNOWSTORM_ENGINE_TID);
		static void PollXboxControllerInput();

		static void XboxSetDeadZones(float trigger, float left_stick, float right_stick);
		static void XboxSetVibration(float left_motor, float right_motor);

		static uint32_t KEY_STATES[256];
		static int MOUSE_X;
		static int MOUSE_Y;
		static int MOUSE_Z;
		static EVENT WINDOW_CLOSE_EVENT_HANDLER;
		static EVENT KEY_PRESS_EVENT_HANDLERS[256];
		static EVENT KEY_RELEASE_EVENT_HANDLERS[256];
		static EVENT KEY_HELD_EVENT_HANDLERS[256];

	private:
		static uint32_t controller_states[XUSER_MAX_COUNT];
		static float xbox_deadzone_trigger;
		static float xbox_deadzone_lp;
		static float xbox_deadzone_ln;
		static float xbox_deadzone_rp;
		static float xbox_deadzone_rn;
		static double frame_timer;

	};
};

#endif